package org.easiermock;

import java.lang.reflect.Method;

/**
 * Annotation-related utility methods
 * 
 * @author Neil Fuller
 */
class AnnotationUtil {
	
	private AnnotationUtil() {
		super();
	}
	
	/**
	 * Retrieve the active Mock annotation for the specified method. 
	 * First checks the method itself, then checks the class where the
	 * method is declared.
	 * 
	 * @param method the method
	 * @return the annotation or null if one cannot be found
	 */
	static Mock getMockMethodAnnotation(Method method) {
		Mock mockAnnotation = method.getAnnotation(Mock.class);
		if (mockAnnotation == null) {
			mockAnnotation = method.getDeclaringClass().getAnnotation(Mock.class);
		}
		return mockAnnotation;
	}

}
